<script>
    class Pet {
    constructor(nickname, age) {
        this.nickname = nickname;
        this.age = age;
    }

    getNickName() {
        return this.nickname;
    }

    getAge() {
        return this.age;
    }
}
class Dog extends Pet {
    constructor(nickname, age, color) {
        super(nickname, age);
        this.color = color;
    }

    getColor() {
        return this.color;
    }
}
const dog = new Dog('旺财', 3, '黄色');
console.log(`宠物昵称: ${dog.getNickName()}`);
console.log(`宠物年龄: ${dog.getAge()}`);
console.log(`宠物颜色: ${dog.getColor()}`);
</script>